<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require '../connect.php'; 

$id=  isset($_GET['id'])?$_GET['id']:0;


if (empty($_POST))//判断$_POST是否有数据 
    {
        $sql="SELECT * FROM tb_ad where id=$id";
        $result=$dd->query($sql);
        $row=$result->fetch_assoc();
        require 'Update.php';
    }
    else
        {
            $id=$_POST['id'];
            $imgurl=$_POST['imgurl'];
            $linkurl=$_POST['linkurl'];
            $isshow=$_POST['isshow'];
            $adname=$_POST['adname'];
            $sql="UPDATE tb_ad SET id = '$id', linkurl = '$linkurl', imgurl = '$imgurl', disshow = '$isshow', adname = '$adname' WHERE id = $id;";
            $result=$dd->query($sql);




            if($result)
            {
                echo "<script language='javascript'type='text/javascript'>";
                echo   " alert('修改成功');";
                echo   " window.location.href='show.php';";
                echo    "</script>";
            }
            else
            {
                echo "<script language='javascript'type='text/javascript'>";
                echo   " alert('修改失败');";
                echo   " window.location.href='show.php';";
                echo    "</script>";
            }
        }
